<?php
declare(strict_types=1);

namespace app\validate;

class CouponOrderValidate extends BaseValidate
{
    protected $rule = [
        'service_id' => 'require|number',
        'business_type' => 'require|in:1,2,3,4,5,6,7,8,9',
        'title' => 'require|length:2,50',
        'order_amount' => 'require|float|gt:0',
        'merchant_commission' => 'require|float|egt:0',
        'platform_commission' => 'require|float|egt:0',
        'order_no' => 'require|length:18,32'
    ];

    protected $message = [
        'service_id.require' => '服务商ID不能为空',
        'service_id.number' => '服务商ID必须为数字',
        'business_type.require' => '业务类型不能为空',
        'business_type.in' => '业务类型不正确',
        'title.require' => '标题不能为空',
        'title.length' => '标题长度必须在2-50个字符之间',
        'order_amount.require' => '订单金额不能为空',
        'order_amount.float' => '订单金额必须为数字',
        'order_amount.gt' => '订单金额必须大于0',
        'merchant_commission.require' => '商家佣金不能为空',
        'merchant_commission.float' => '商家佣金必须为数字',
        'merchant_commission.egt' => '商家佣金必须大于等于0',
        'platform_commission.require' => '平台佣金不能为空',
        'platform_commission.float' => '平台佣金必须为数字',
        'platform_commission.egt' => '平台佣金必须大于等于0',
        'order_no.require' => '订单号不能为空',
        'order_no.length' => '订单号长度必须在18-32个字符之间'
    ];

    // 领取优惠券场景
    public function sceneReceive(): CouponOrderValidate
    {
        return $this->only(['service_id', 'business_type', 'title', 'order_amount', 'merchant_commission', 'platform_commission']);
    }

    // 订单回调场景
    public function sceneCallback(): CouponOrderValidate
    {
        return $this->only(['order_no']);
    }
} 